import React from 'react'
import PropTypes from 'prop-types'
import {
  View,
  StyleSheet,
  Text,
  Fragment
} from 'react-native'
import CustomButton from 'src/components/button/CustomButton'
import { ScaleS, ScaleT, IS_IPHONEX } from 'src/utils/ScreenUtil'

export default class JobHuntingOperateModel extends React.Component {
  static defaultProps = {
    type: '',
    dataArr: []
  }

  static propTypes = {
    addJobHunting: PropTypes.func,
    editJobHunting: PropTypes.func,
    deleteJobHunting: PropTypes.func,
    type: PropTypes.string,
    dataArr: PropTypes.array
  }

  render () {
    const { type, dataArr } = this.props
    return (
      <View style={styles.view}>
        <CustomButton onPress={this._addJobHunting} style={styles.button}>
          <Text style={styles.buttonText}>{type === 'photo' ? '上传' : '添加'}</Text>
        </CustomButton>
        {!!dataArr && dataArr.length > 0 && type !== 'photo' && <CustomButton onPress={this._editJobHunting} style={styles.button}>
          <Text style={styles.buttonText}>修改</Text>
        </CustomButton>}
        {!!dataArr && dataArr.length > 0 && <CustomButton onPress={this._deleteJobHunting} style={styles.button}>
          <Text style={styles.buttonText}>删除</Text>
        </CustomButton>}

      </View>
    )
  }

  _addJobHunting = () => {
    this.props.addJobHunting()
  }

  _editJobHunting = () => {
    this.props.editJobHunting()
  }

  _deleteJobHunting = () => {
    this.props.deleteJobHunting()
  }
}

const styles = StyleSheet.create({
  view: {
    width: '100%',
    borderTopLeftRadius: ScaleS(12),
    borderTopRightRadius: ScaleS(12),
    backgroundColor: '#fff',
    paddingTop: ScaleS(40),
    paddingBottom: IS_IPHONEX ? ScaleS(30) : ScaleS(0),
    paddingLeft: ScaleS(30)
  },
  button: {
    width: '100%',
    marginBottom: ScaleS(40)
  },
  buttonText: {
    fontSize: ScaleT(18),
    color: '#000000'
  }
})
